//package nbcp.db
//
//import nbcp.db.IdName
//import nbcp.base.extend.*
//import nbcp.base.utils.RecursionReturnEnum
//import nbcp.base.utils.RecursionUtil
//import nbcp.db.mongo.*
//import nbcp.db.mongo.entity.SysCorporation_Role
//import nbcp.db.mongo.entity.SysCorporation
//import nbcp.db.mongo.entity.SysLoginUser
//import nbcp.db.mongo.entity.SysUser
//import nbcp.db.mongo.*
//import nbcp.db.mongo.table.*
//
//fun SystemGroup.SysUserEntity .doRegiste(loginName: String, password: String, corpName: String, userName: String): SysUser {
//
//    val adminRole = SysCorporation_Role(name = "管理员");
//
//    val jwdDefine = mor.system.sysCorporationDefinition
//            .query(mor.system.sysCorporationDefinition.corpRole match CorpRoleEnum.Shop)
//            .toEntity();
//
//    if (jwdDefine != null) {
//        val menuIds = mutableListOf<String>();
//        RecursionUtil.execute(jwdDefine.menus, { it.subMenus }, { it, parent, index ->
//            menuIds.add(it.code)
//            return@execute RecursionReturnEnum.Go
//        })
//        adminRole.menus.addAll(menuIds.distinct());
//    }
//
//    adminRole.menus = adminRole.menus.distinct().toMutableList();
//
//    val corp = SysCorporation();
//    corp.name = corpName;
//    corp.menus = adminRole.menus;
//    corp.corpRole = CorpRoleEnum.Empty;
//    corp.locked = true;
//    corp.lockedRemark = "需要审核";
//
//    mor.system.sysCorporation.insert(corp);
//
////    val modifyCorp = SysCorporation();
////    modifyCorp.id = corp.id//使两表的id保持一致
////    modifyCorp.name = corpName;
////
////    mor.system.sysCorporation.insert(modifyCorp);
//
//
//    val user = SysUser();
//    user.corp = IdName(corp.id, corp.name);
//    user.loginName = loginName;
//    // user.mobile = loginName;
//    user.menus = adminRole.menus;
//    user.name = userName + "管理员"
//    user.leader = true;
//    user.status = UserStatusEnum.Job;
//    user.admin = true;
//    mor.system.sysUser.insert(user)
//
//
//    val loginUser = SysLoginUser();
//    loginUser.id = user.id;
//    loginUser.loginName = loginName;
//    loginUser.password = password;
//
//    mor.system.sysLoginUser.insert(loginUser);
//
//    return user;
//}